package com.wxxymaker.utils;

import java.util.Base64;

/**
 * @Author: Soft
 * @Date: 2018/7/15 16:06
 * @Desc: base64加密
 */
public class Base64Util {

    private static Base64.Decoder decoder = Base64.getDecoder();
    private static Base64.Encoder encoder = Base64.getEncoder();

    public static String decode(String base64) {
        if (base64 != null && !"".equals(base64)) {
            byte[] decode = decoder.decode(base64);
            return new String(decode);
        }
        return base64;
    }

    public static String encode(String str) {
        if (str != null) {
            return encoder.encodeToString(str.getBytes());
        }
        return str;
    }
}
